#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：HIflys-api-Test 
@File    ：read.py
@Author  ：beibei
@Date    ：2024/12/27 5:25 PM 
'''
import configparser
import os
import yaml


data_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "data", "data.yaml")
products_data_path=os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "products_data", "products_data.yaml")
ini_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "config", "settings.ini")
file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "file", "upload.jpeg")


class FileRead:
    def __init__(self):
        self.products_data_path = products_data_path
        self.data_path = data_path
        self.ini_path = ini_path
        self.file_path = file_path

    def read_data(self):
        f = open(self.data_path, encoding="utf8")
        data = yaml.safe_load(f)
        # print(data)
        return data

    def read_productsdata(self):
        f = open(self.products_data_path, encoding="utf8")
        products_data = yaml.safe_load(f)
        # print(data)
        return products_data

    def read_file(self):
        file = open(self.file_path, 'rb')
        return {'file': ('upload.jpeg', file, 'image/jpeg')}

    def read_ini(self):
       # 解析配置文件的模块，通常用于读取和写入INI文件格式的配置文件
        config = configparser.ConfigParser()
        config.read(self.ini_path, encoding='utf8')
        return config


base_data = FileRead()
products_data_path= FileRead()
print(base_data.read_data())
